package com.example.mybatisplus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mybatisplus.model.domain.AuditHistory;
import com.example.mybatisplus.mapper.AuditHistoryMapper;
import com.example.mybatisplus.model.dto.PageDTO;
import com.example.mybatisplus.service.AuditHistoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lxp
 * @since 2023-01-05
 */
@Service
public class AuditHistoryServiceImpl extends ServiceImpl<AuditHistoryMapper, AuditHistory> implements AuditHistoryService {

    @Autowired
    private AuditHistoryMapper auditHistoryMapper;

    @Override
    public Page<AuditHistory> pageList(AuditHistory auditHistory, PageDTO pageDTO) {
        Page<AuditHistory> page = new Page<>(pageDTO.getPageNo(),pageDTO.getPageSize());
        QueryWrapper<AuditHistory> wrapper=new QueryWrapper<>();
        if (StringUtils.isNotBlank(auditHistory.getName())){
            wrapper.like("name",auditHistory.getName());
        }
        auditHistoryMapper.selectPage(page,wrapper);
        return page;
    }
}
